package com.zdsoft.crm.service.auth.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zdsoft.crm.dao.auth.ISysFunctionMapper;
import com.zdsoft.crm.entity.auth.SysFunction;
import com.zdsoft.crm.service.auth.ISysFunctionService;
import com.zdsoft.crm.vo.PageVo;

@Service
@Transactional
public class SysFunctionServiceImpl implements ISysFunctionService{

	@Autowired
	ISysFunctionMapper iSysFunctionMapper;
	
	//添加
	@Override
	public void save(SysFunction func) {
		iSysFunctionMapper.save(func);
	}

	//查询
	@Override
	public List<SysFunction> findAll() {
		List<SysFunction> findAll= iSysFunctionMapper.findAll();
		return findAll;
	}

	//删除
	@Override
	public void deleteById(String id) {
		iSysFunctionMapper.deleteById(id);
	}

	//修改
	@Override
	public void update(SysFunction func) {
		iSysFunctionMapper.update(func);
	}

	//分页
	@Override
	public PageVo findPage(Integer pageNum, Integer pageSize) {
		PageVo pageVo = new PageVo();
		pageVo.setPageNum(pageNum);
		pageVo.setPageSize(pageSize);
		int beginIndex = (pageNum - 1) * pageSize;
		int endIndex = beginIndex + pageSize;
		pageVo.setList(iSysFunctionMapper.pageList(beginIndex, endIndex));
		// pageVo.setList(dao.pageList((pageNum - 1) * pageSize, pageSize));
		// mysql
		// pageVo.setList(dao.pageList(pageNum, pageSize));
		pageVo.setTotalCount(iSysFunctionMapper.totalCount().intValue());
		return pageVo;
	}

	//根据id查询单条
	@Override
	public SysFunction findOne(SysFunction func) {
		SysFunction sysFunction=iSysFunctionMapper.findOne(func);
		return sysFunction;
	}

	@Override
	public List<SysFunction> findByUserId(String userId) {
		return iSysFunctionMapper.findByUserId(userId);
	}

	
}
